package com.cloud.cookie;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

@RestController
public class CookieController {
    //host文件
//    127.0.0.1   www.mall.com
//    127.0.0.1   www.test1.mall.com

    @GetMapping("/setCookie")
    private void setCookie(HttpServletResponse response) {
        Cookie cookie = new Cookie("userName", "Tom");
        cookie.setDomain("mall.com");
        cookie.setHttpOnly(true);
        cookie.setMaxAge(10);
        response.addCookie(cookie);
    }

    @GetMapping("/getCookies")
    private String getCookies() {
        return "ok";
    }
}
